<?php
defined('_JEXEC') or die('Restricted access'); 
 
jimport( 'joomla.html.html.tabs' );
JHtml::_('jquery.framework');
JHtml::_('behavior.keepalive');
JHTML::_('behavior.tooltip'); 
JHtml::_('behavior.framework');
?>
 
<script type="text/javascript" src="<?php echo JURI::base(true)?>/components/com_wrd/assets/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
	
	Joomla.submitbutton = function(pressbutton){
		var reg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
		
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
		if (pressbutton == 'save') {
			if (document.adminForm.name.value == "") {
				alert( 'Must have name !' );
				document.adminForm.name.focus();
				return false;
			}

			if (document.adminForm.type.value == "admin") {
				if (document.adminForm.email.value == "") {
					alert( 'Must have at least a email !' );
					document.adminForm.email.focus();
					return false;
				}
			}
			if (document.adminForm.action.value == "") {
				alert( 'Must have action !' );
				document.adminForm.action.focus();
				return false;
			}
			
			submitform( pressbutton );
		}
	}
	
</script>
<script type="text/javascript">
	jQuery.noConflict();
	jQuery(document).ready(function(){
		if(jQuery("select#action option:selected").val()=='pickup_notice'){
			jQuery(".template_d1").removeClass("display_none");
		}else{
			jQuery(".template_d1").addClass("display_none");
		}
        jQuery("#action").change(function(){
        	if(jQuery("select#action option:selected").val()=='pickup_notice'){
    			jQuery(".template_d1").removeClass("display_none");
    		}else{
    			jQuery(".template_d1").addClass("display_none");
    		}
            jQuery("#parrams").text('Loading...').load('<?php print JRoute::_('index.php?option=com_wrd&controller=cemail&layout=parrams&tmpl=component',false); ?>',{'act':jQuery("#action").val()});
        })
        jQuery("#parrams").text('Loading...').load('<?php print JRoute::_('index.php?option=com_wrd&controller=cemail&layout=parrams&tmpl=component',false); ?>',{'act':jQuery("#action").val()});
		//alert(jQuery("#action").val());
    	});
</script>
<style type="text/css">
	.display_none{
		display: none;
	}
</style>
<form action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="adminForm" id="adminForm" >
	<div class="col width-60" style="float:left; width:60%">
	    <fieldset class="adminform">
	    	<legend><?php echo JText::_('Details')?></legend>
			<table class="table table-striped adminlist">
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Name')?>:</label>
					</td>
					<td colspan="2">
						<input type="text" title="type" maxlength="50" size="50" value="<?php echo $this->data->name; ?>" id="name" name="name" class="name"/> *
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Type')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['type_user']; ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Email (admin)')?>:</label>
					</td>
					<td colspan="2">
						<input type="text" title="email" size="50" value="<?php echo $this->data->email; ?>" id="email" name="email" class="email"/> *
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Action')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['action']; ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Email Subject')?>:</label>
					</td>
					<td colspan="2">
						<input type="text" title="Subject" size="50" value="<?php echo $this->data->subject; ?>" id="subject" name="subject" class="subject" /> *
					</td>
				</tr>
				<tr>
					<td class="key" valign="top">
						<label for="title"><?php echo JText::_('Template (English)')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['des']; ?>
					</td>
				</tr>
				<tr>
					<td class="key" valign="top">
						<label for="title"><?php echo JText::_('Template (Vietnamese)')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['template_vi']; ?>
					</td>
				</tr>
				<tr class='template_d1 display_none'>
					<td class="key" valign="top">
						<label for="title"><?php echo JText::_('Template (English) for District 1')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['template_d1']; ?>
					</td>
				</tr>
				<tr class='template_d1 display_none'>
					<td class="key" valign="top">
						<label for="title"><?php echo JText::_('Template (Vietnamese) for District 1')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['template_d1_vi']; ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Publish')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['published']; ?>
					</td>
				</tr>
            </table>
		</fieldset>
	</div>
	<div id="parrams" style="float:right; margin-top: 10px; width: 36%;">
	</div>
	<input type="hidden" name="created_id" value="<?php echo $this->user->id;?>" />
	<input type="hidden" name="controller" value="cemail" />
	<input type="hidden" name="option" value="com_wrd" />
	<input type="hidden" name="id" value="<?php echo (int)$this->data->id; ?>" />
	<input type="hidden" name="task" value="" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>
